<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RxJS Demo</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .demo-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        .demo-section {
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            background: #fafafa;
        }
        .demo-section h3 {
            margin-top: 0;
            color: #007bff;
        }
        .output {
            background: #f8f8f8;
            padding: 10px;
            border-radius: 4px;
            font-family: monospace;
            white-space: pre-wrap;
            max-height: 300px;
            overflow-y: auto;
            min-height: 100px;
            border: 1px solid #ddd;
        }
        button {
            background: #007bff;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
            margin: 5px 5px 5px 0;
            font-size: 14px;
        }
        button:hover {
            background: #0056b3;
        }
        button.danger {
            background: #dc3545;
        }
        button.danger:hover {
            background: #c82333;
        }
        .controls {
            margin-bottom: 10px;
        }
        .description {
            font-size: 14px;
            color: #666;
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>RxJS Operators Demo Collection</h1>
        
        <div class="demo-grid">
            <div class="demo-section">
                <h3>CombineAll Operator</h3>
                <div class="description">
                    将高阶 Observable 转换为一阶 Observable，使用 combineLatest 策略组合内部 Observables
                </div>
                <div class="controls">
                    <button id="combineAllBtn">运行 CombineAll</button>
                    <button id="clearCombineAllBtn" class="danger">清空</button>
                </div>
                <div id="combineAllOutput" class="output"></div>
            </div>

            <div class="demo-section">
                <h3>ForkJoin Operator</h3>
                <div class="description">
                    等待所有 Observable 完成，然后发出每个 Observable 的最后一个值
                </div>
                <div class="controls">
                    <button id="forkJoinBtn">运行 ForkJoin</button>
                    <button id="clearForkJoinBtn" class="danger">清空</button>
                </div>
                <div id="forkJoinOutput" class="output"></div>
            </div>

            <div class="demo-section">
                <h3>WithLatestFrom Operator</h3>
                <div class="description">
                    当源 Observable 发出值时，结合其他 Observable 的最新值一起发出
                </div>
                <div class="controls">
                    <button id="withLatestFromBtn">运行 WithLatestFrom</button>
                    <button id="clearWithLatestFromBtn" class="danger">清空</button>
                </div>
                <div id="withLatestFromOutput" class="output"></div>
            </div>

            <div class="demo-section">
                <h3>Merge Operator</h3>
                <div class="description">
                    将多个 Observable 合并为一个，按时间顺序发出所有值
                </div>
                <div class="controls">
                    <button id="mergeBtn">运行 Merge</button>
                    <button id="clearMergeBtn" class="danger">清空</button>
                </div>
                <div id="mergeOutput" class="output"></div>
            </div>

            <div class="demo-section">
                <h3>ConcatMap Operator</h3>
                <div class="description">
                    将每个源值映射为 Observable，然后按顺序连接输出
                </div>
                <div class="controls">
                    <button id="concatMapBtn">运行 ConcatMap</button>
                    <button id="clearConcatMapBtn" class="danger">清空</button>
                </div>
                <div id="concatMapOutput" class="output"></div>
            </div>
        </div>
        
        <div style="text-align: center; margin-top: 20px;">
            <button id="clearAllBtn" class="danger" style="font-size: 16px; padding: 10px 20px;">清空所有输出</button>
        </div>
    </div>
</body>
</html>